package com.starinside.wp.domain;

import com.starinside.wp.foundation.constant.ChildrenConstant;
import com.starinside.wp.foundation.model.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * Created by Tim.
 * form com.matt
 * on 2017/7/13
 * *******************************
 */
@Entity
@Data
@Table(name = "children")
@EqualsAndHashCode(callSuper = true)
//@NoArgsConstructor
public class Children extends Model {

    @Column(columnDefinition = " varchar(50)  COMMENT '宝宝姓名'")
    private String name;

    @Column(columnDefinition = " varchar(32)  COMMENT ' 学籍号:  行政区划代码+园区顺序号+年份+月份+入园顺序号+性别'")
    private String code;

    @Column(columnDefinition = " varchar(50)  COMMENT '宝宝昵称'")
    private String nickName="";

    @Column(columnDefinition = " int default 0  COMMENT '宝宝性别 ：0：女，1：男'")
    private Integer gender;

    @Column(name = "aid", columnDefinition = " varchar(32)  COMMENT ' 园区id：园区姓名'")
    private String areaId;

    @Column(columnDefinition = " varchar(255)  COMMENT '地址'")
    private String address = "";

    @Column(columnDefinition = " datetime COMMENT '宝宝生日'")
    private Date birthday;

    @Column(columnDefinition = " varchar(50)  COMMENT '体重'")
    private String weight;

    @Column(columnDefinition = " varchar(50)  COMMENT '身高'")
    private String height;

    @Column(columnDefinition = " varchar(50)  COMMENT '头围'")
    private String header;

    @Column(columnDefinition = " varchar(255)  COMMENT '备注'")
    private String remark = "";

    @Column(columnDefinition = " varchar(512)  COMMENT '头像地址'")
    private String imgUrl;

    @Column(columnDefinition = " bigint default 0 COMMENT '焦虑期'")
    private Long anxietyTime = 0L;

    @Column(name = "createTime", columnDefinition = "datetime default NOW() COMMENT '宝宝生日'")
    private Date created = new Date();

    @Column(columnDefinition = "datetime COMMENT '课程开始时间'")
    private Date courseStartDate;

    @Column(columnDefinition = "int default 0 COMMENT '托班是否可用， 0:未生效, 1:正常，2 合同结束, 3:已退学，4:已毕学 '")
    private Integer status = 0;

    @Column(columnDefinition = " varchar(32)  COMMENT '录入员工id'")
    private String staffId;

    @Column(columnDefinition = " varchar(50)  COMMENT '对应crm客户id'")
    private String crmClienteleId;

    @Column(columnDefinition = "bit default false COMMENT '是否展示'")
    private Boolean isDisplayForAdmin = false;

    @Column(columnDefinition = "longtext COMMENT '托班转班原因'")
    private String nurseryTransferReason;

    @Column(columnDefinition = "longtext COMMENT '早教转班原因'")
    private String earlyTransferReason;

    @Column(columnDefinition = " varchar(255)  COMMENT '优惠卷码'")
    private String couponCard;

    public Children(){

    }

    public Children(String childrenName, String nickName, Integer gender, Date birthday, String weight, String height, String header, String address){
        this.setName(childrenName);
        this.setNickName(nickName);
        this.setGender(gender);
        this.setAddress(address);
        this.setStatus(ChildrenConstant.ChildrenStatus.ACTIVE.codeOf());
        this.setBirthday(birthday);
        this.setHeight(height);
        this.setWeight(weight);
        this.setHeader(header);
    }

    public static Children of(String name, String nickName, Integer gender, Date birthday, String areaId, String address, String crmClienteleId, String staffId){
        Children children = new Children();
        children.setName(name);
        children.setNickName(nickName);
        children.setBirthday(birthday);
        children.setStatus(ChildrenConstant.ChildrenStatus.NON_ACTIVE.codeOf());
        children.setAreaId(areaId);
        children.setAddress(address);
        children.setStaffId(staffId);
        children.setCrmClienteleId(crmClienteleId);
        children.setGender(gender);
        return children;
    }

    public static Children of_new(String name, String nickName, Integer gender, Date birthday, String areaId, String address, String crmClienteleId, String staffId,String weight,String height,String header,String remark){
        Children children = new Children();
        children.setName(name);
        children.setNickName(nickName);
        children.setBirthday(birthday);
        children.setStatus(ChildrenConstant.ChildrenStatus.NON_ACTIVE.codeOf());
        children.setAreaId(areaId);
        children.setAddress(address);
        children.setStaffId(staffId);
        children.setCrmClienteleId(crmClienteleId);
        children.setGender(gender);
        children.setWeight(weight);
        children.setHeader(header);
        children.setHeight(height);
        children.setRemark(remark);
        return children;
    }
}
